package com.bristua.common.biz;

import com.bristua.common.dao.TIndexImgMapper;
import com.bristua.common.model.TIndexImg;
import com.bristua.common.utils.DateUtil;
import com.bristua.common.utils.SequenceUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2019/4/29.
 */
@Service
@Transactional
public class AddAppIndexImgBiz {

    @Resource
    private TIndexImgMapper tIndexImgMapper;

    public void addAppIndexImgBiz(TIndexImg tIndexImg){
        if(StringUtils.isEmpty(tIndexImg.getIndexImgUrlId())){
            tIndexImg.setCreateTime(DateUtil.getDateTime3());
            tIndexImg.setIndexImgUrlId(SequenceUtil.nextId());
            tIndexImg.setStatus(1);
            tIndexImgMapper.insert(tIndexImg);
        }else{
            tIndexImgMapper.updateByPrimaryKeyWithBLOBs(tIndexImg);
        }

    }
    public void delAppIndexImg(String indexImgUrlId){
        tIndexImgMapper.deleteByPrimaryKey(indexImgUrlId);
    }

}
